//
//  UILabel + Extension.swift
//  sinaWeibo7110
//
//  Created by 安静清晨 on 2017/1/5.
//  Copyright © 2017年 walk-in-minds. All rights reserved.
//

import UIKit

extension UILabel{
    
    
    convenience init(title:String, BGImageName:String, size:CGFloat, color:UIColor){
        
        self.init()
        
        self.text = title
        self.textAlignment = NSTextAlignment.center
        self.font = UIFont.systemFont(ofSize: size)
        self.textColor = color
        self.sizeToFit()
        
        
        
    }
    
    
    
    
}

extension UIImage {
    //class声明的方法是类方法
    class func snapshotCurrentScreen() -> UIImage {
        //1.开启图形上下文
        let window = UIApplication.shared.keyWindow!
        UIGraphicsBeginImageContextWithOptions(window.bounds.size, false, 0)
        //2. 将window 绘制到图层上下文中
        window.drawHierarchy(in: window.frame, afterScreenUpdates: true)
        //3. 从上下文中获取图片对象
        let image = UIGraphicsGetImageFromCurrentImageContext()
        //4. 关闭图形上下文
        UIGraphicsEndImageContext()
        //返回结果
        return image!
    }
}
